﻿Imports System.Text

Public Class ColumnUtil

    Public Shared Function 列(ByVal dr As DataRow) As String

        Dim sb As New StringBuilder
        sb.Append("[" & CStr(dr("columnname")) & "] " & "[" & CStr(dr("typename")) & "]")
        sb.Append("(")

        If CInt(dr("precision")) <> 0 Then
            sb.Append(CInt(dr("precision")) & "," & CInt(dr("scale")))
        ElseIf CInt(dr("max_length")) <> 0 Then
            If CInt(dr("max_length")) <> -1 Then
                If CStr(dr("typename")) = "nvarchar" Then
                    sb.Append(CInt(dr("max_length")) / 2)
                Else
                    sb.Append(CInt(dr("max_length")))
                End If
            Else
                sb.Append("MAX")
            End If
        End If
        sb.Append(")")

        Return sb.ToString

    End Function

End Class
